<!DOCTYPE html>
<html class="x-admin-sm">

<head>
    <meta charset="UTF-8">
    <title>万息金融-后台管理</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8"/>
    <link rel="stylesheet" href="/admin/css/font.css">
    <link rel="stylesheet" href="/admin/css/xadmin.css">
    <script type="text/javascript" src="/admin/lib/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="/admin/js/xadmin.js"></script>
    <script src="/admin/js/jquery.min.js"></script>
    <script src="/admin/js/myAjax.js"></script>
    <script src="/admin/js/common.js"></script>
    <script src="/admin/js/companyInfo.js"></script>
    <script src="/admin/js/intercept.js"></script>
</head>
<body>
<div class="layui-fluid">
    <div class="layui-row">
        <form class="layui-form">
            <!--LOGO栏-->
            <div class="layui-form-item">
                <label for="picUpload" class="layui-form-label">
                    <span class="x-red">*</span>LOGO</label>
                <!--图片上传-->
                <div class="layui-upload-drag" id="picUpload">
                    <i class="layui-icon"></i>
                    <p>点击上传，或将文件拖拽到此处</p>
                    <div id="uploadDemoView">
                        <hr>
                        <img id="Logo" src="" alt="上传成功后渲染" style="max-width: 196px">
                    </div>
                </div>

                <div class="layui-form-mid layui-word-aux">
                    &nbsp; &nbsp;&nbsp;&nbsp;&nbsp; &nbsp; &nbsp;&nbsp;&nbsp;&nbsp; &nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                    <span class="x-red">*</span>上传不超过300kB的jpg格式图片
                </div>
            </div>
            <!--公司名称-->
            <div class="layui-form-item">
                <label for="name" class="layui-form-label">
                    <span class="x-red">*</span>名称</label>
                <div class="layui-input-inline">
                    <input type="text" id="name" name="name" required="true" lay-verify="name"
                           autocomplete="off" class="layui-input"></div>
            </div>
            <!--公司英文名-->
            <div class="layui-form-item">
                <label for="englishName" class="layui-form-label">
                    <span class="x-red">*</span>英文名</label>
                <div class="layui-input-inline">
                    <input type="text" id="englishName" name="englishName" required="true" lay-verify="englishName" autocomplete="off"
                           class="layui-input"></div>
                <div class="layui-form-mid layui-word-aux"></div>
            </div>
            <!--公司电话-->
            <div class="layui-form-item">
                <label for="phone" class="layui-form-label">
                    <span class="x-red">*</span>电话</label>
                <div class="layui-input-inline">
                    <input type="text" id="phone" name="phone" required="true" lay-verify="phone" autocomplete="off"
                           class="layui-input"></div>
            </div>

            <!--邮箱-->
            <div class="layui-form-item">
                <label for="email" class="layui-form-label">
                    <span class="x-red">*</span>邮箱</label>
                <div class="layui-input-inline">
                    <input type="text" id="email" name="email" required="true" lay-verify="email" autocomplete="off"
                           class="layui-input"></div>
            </div>

            <!--地址-->
            <div class="layui-form-item">
                <label for="address" class="layui-form-label">
                    <span class="x-red">*</span>地址</label>
                <div class="layui-input-inline">
                    <input type="text" id="address" name="address" required="true"  autocomplete="off"
                           class="layui-input"></div>
            </div>

            <!--网站备案-->
            <div class="layui-form-item">
                <label for="icp" class="layui-form-label">
                    <span class="x-red">*</span>网站备案</label>
                <div class="layui-input-inline">
                    <input type="text" id="icp" name="icp" required="true" lay-verify="" autocomplete="off" cglass="layui-input"></div>
            </div>

            <!--确认修改-->
            <div class="layui-form-item">
                <label for="submit" class="layui-form-label"></label>
                <button id="submit" class="layui-btn" lay-filter="update" lay-submit="">确认</button>
            </div>
        </form>


    </div>
</div>
<script>



    layui.use(['upload', 'element', 'layer'], function () {
        var $ = layui.jquery
            , upload = layui.upload
            , element = layui.element
            , layer = layui.layer;
//拖拽上传
        upload.render({
            elem: '#picUpload'
            , url: ipAddress()+'/image/upload' //此处用的是第三方的 http 请求演示，实际使用时改成您自己的上传接口即可。
            , size: 300 //限制文件大小，单位 KB
            , done: function (res) {
                layer.msg('上传成功');
                layui.$('#uploadDemoView').removeClass('layui-hide').find('img').attr('src', res.msg);
            }
        });
    });


    layui.use(['form', 'layer', 'jquery'],
        function () {
            $ = layui.jquery;
            var form = layui.form,
                layer = layui.layer;

            //自定义验证规则

                form.verify({
                name:function (value,item) {
                    if(!new RegExp("[\u4e00-\u9fa5]+").test(value)){
                        return '公司名只能为中文';
                    }
                }
                ,englishName:function (value,item) {
                    if(!new RegExp("^[a-zA-Z]{1,15}([a-zA-Z]* ?[a-zA-Z]*)*[a-zA-Z]$").test(value)){
                        return "请输入英文名字:以字母开头和结尾";
                    }
                }
            });

            //监听提交
            form.on('submit(update)',
                function (data) {

                    data = data.field;
                    data.logo=$("#Logo").attr("src");
                    let res=myAjax(ipAddress()+'/company/u',data,'put');
                    if(res.count==1) {
                        //发异步，把数据提交给php
                        layer.alert("修改成功", {
                                icon: 6
                            },

                            function () {
                                //关闭当前frame
                                xadmin.close();
                                // 可以对父窗口进行刷新
                                xadmin.father_reload();
                            });
                        return false;
                    }else{
                         layer.alert('上传失败',{icon:5})
                    }

                });

        });</script>

</body>

</html>